package Work;

import Project.Demo;

// 实现交换两个变量的值，需要交换实参的值
class DemoNum{
    private int num;

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }
}


public class Work5 {
    public static void swap(DemoNum demonum1,DemoNum demonum2) {
        int tmp = demonum1.getNum();
        demonum1.setNum(demonum2.getNum());
        demonum2.setNum(tmp);

    }
    public static void main(String[] args) {
        DemoNum demonum1 = new DemoNum();
        demonum1.setNum(99);

        DemoNum demonum2 = new DemoNum();
        demonum2.setNum(999);

        System.out.println("交换前:");
        System.out.print("demonum1:"+demonum1.getNum());
        System.out.print(" ,demonum2:"+demonum2.getNum());
        swap(demonum1,demonum2);
        System.out.println("\n交换后");
        System.out.print("demonum1:"+demonum1.getNum());
        System.out.print(" ,demonum2:"+demonum2.getNum());

    }



    public static void main1(String[] args) {
        int i = 0;
        int j = 1;
        for( i=0 ,j=1;j < 5; j+=3) {

            i+=j; // i  = 0 +1=1; j=j+3=4,i=1+4=5;j=4+3=7
        }
        System.out.println(i);

        String str = "你好世界";
//        int i = 1;
        System.out.println(str+i);


        int a[] = {1,23,4};
        int[] b;
        b = new int[]{1,2,3};

        int d = 0;
        int sum = 0;
        while(i<=10) {
            sum += i;
            i++;
            /*if(i%2==0) {
                continue;
            }*/
        }
        System.out.println(sum);


        /*
      int x = 100;
        switch(x) {
            case 100:
                System.out.println("100");
                break;
            case 200:
                System.out.println("200");
                break;
        }

        */

      /*
        short s1 =1;
        s1=s1+1;

       */
    }
}
